home *** CD-ROM | disk | FTP | other *** search
- Path: news1.h1.usa.pipeline.com!usenet
- From: grantp@usa.pipeline.com(Pete)
- Newsgroups: comp.lang.c++
- Subject: Re: trouble with command line args, need help
- Date: 19 Feb 1996 23:58:18 GMT
- Organization: Kalevi, Inc.
- Message-ID: <4gb2qq$197@news1.usa.pipeline.com>
- NNTP-Posting-Host: pipe15.h1.usa.pipeline.com
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete)
- X-Newsreader: Pipeline USA v3.3.0
-
- On Feb 18, 1996 21:20:56 in article <trouble with command line args, need
- help>, 'thecrow@iconn.net (The Crow)' wrote:
-
-
- >Hey, I have a program that has three strings defined as such
- >
- >char key[80];
- >char ifn[12];
- >char ed[1];
- >
- >Then I read in the command line arguments in the main function like so:
- >
- >main(int argc, char* argv[]) {
- >blablabla
- >}
- >
- >then inside the main function I try to do this
- >
- >ifn = argv[1];
- >ed = argv[2];
- >key = argv[3];
- >
- The C++ way:
-
- #include <strstrea.h> (MSVC++4.0 name)
-
- ostrstream os(key, 80);
- os << argv[1] << ends;
- - - - - - - -
- The C way:
- #include <string.h>
-
- strcpy(key, argv[1);
-
- While the C++ way is safe, C is not -- you should make
- sure that the receiving string is large enough.
-
- --
- Pete Grant
- Kalevi, Inc.
- Software Engineering & development
-